﻿using Lhz.Data;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Lhz.Common.Business
{
    public interface IEntityProxy : IDisposable
    {
        IQueryable<TEntity> CreateQueryable<TEntity>() where TEntity : class;

        void ClearCache();
    }

    public interface IEntityProxy<TPk, TEntity> : IEntityProxy where TEntity : class
    {
        IQueryable<TEntity> CreateQueryable();

        List<TEntity> Query();

        List<TEntity> Query(Pagination pagination);

        List<TEntity> Query(List<OrderBy> orderBies);

        List<TEntity> Query(Pagination pagination, List<OrderBy> orderBies);

        TEntity QueryByPk(TPk pk);

        void Add(TEntity item);

        void Add(IEnumerable<TEntity> items);

        void Update(TEntity item);

        void Update(IEnumerable<TEntity> items);

        void Delete(TEntity item);

        void Delete(IEnumerable<TEntity> items);

        void DeleteByPk(TPk pk);

        void DeleteByPk(IEnumerable<TPk> pks);
    }
}
